package com.cloud.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

@org.springframework.context.annotation.Configuration
public class Configuration {
    /**
     * 路由转发
     *
     * @param builder
     * @return
     */
    @Bean
    public RouteLocator customerRouteLoader(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder route = builder.routes();
        route.route("path_route_fzx1", r -> r.path("/payment").uri("http://localhost:8001/user-api/payment/getServices")).build();
        return route.build();
    }

    /**
     * 路由转发
     *
     * @param builder
     * @return
     */
    @Bean
    public RouteLocator customerRouteLoader2(RouteLocatorBuilder builder) {
        RouteLocatorBuilder.Builder route = builder.routes();
        route.route("path_route_fzx2", r -> r.path("/guonei").uri("http://news.baidu.com/")).build();
        return route.build();
    }
}
